﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Sql;

namespace 学生成绩查询及选课系统.teacher
{
    public partial class showClass : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bind();
            }
        }

        public void bind()
        {
            string sql = "select class.classname as '班名',count(student.stuno) as '班级人数' from class" +
          " join student on class.classno=student.classno" +
          " join teach on class.classno=teach.classno" +
          " join teacher on teach.tno=teacher.tno" +
          " group by classname,teacher.tno,class.clastate having class.clastate=1 and teacher.tno=" +Session["user"].ToString();
            DataTable dt=DBAccess.GetTable(sql);
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
    }
}